<template>
  <div style="margin-bottom: 50px">
    <div>
      <!-- 标题 -->
      <div class="title">推荐歌单</div>
      <!-- 放图片的盒子 -->
      <div class="pic-box">
        <van-row gutter="5">
          <van-col v-for="item in recList" :key="item.id" span="8">
            <img style="width: 100%; height: 120px;" :src="item.picUrl" alt="" />
            <div class="song_name">{{ item.name }}</div>
          </van-col>
        </van-row>
      </div>
    </div>

    <!-- 推荐歌曲列表 -->
    <div>
      <div class="title">最新音乐</div>
      <van-cell-group>

        <music-cell 
          v-for="item in musicList" 
          :key="item.id" 
          :title="item.name"
          :id="item.id"
          :label="`${item.song.artists[0].name} - ${item.name}`"
        />

        <!-- <van-cell :title="item.name" :label="`${item.song.artists[0].name} - ${item.name}`">
          <template #right-icon>
            <div style="display:flex; align-items:center;">
              <van-icon size="24" name="play-circle-o" />
            </div>
          </template>
        </van-cell> -->

      </van-cell-group>
    </div>
  </div>
</template>

<script>
// 导入接口
import { recommandList, newMusic } from "@/api/home";
export default {
  data() {
    return {
      recList: [],
      musicList: []
    };
  },
  async created() {
    // 发请求获取推荐歌单数据
    const res = await recommandList(6);
    this.recList = res.data.result;

    const res2 = await newMusic()
    this.musicList = res2.data.result
  },
};
</script>

<style>
/* 标题 */
.title {
  padding: 10px 15px;
  margin: 0 0 15px 0;
  background-color: #eee;
  color: #333;
  font-size: 15px;
}
/* 推荐歌单 - 歌名 */
.song_name {
  font-size: 14px;
  padding: 0 5px;
  margin-bottom: 10px;
  word-break: break-all;
  text-overflow: ellipsis;
  display: -webkit-box; /** 对象作为伸缩盒子模型显示 **/
  -webkit-box-orient: vertical; /** 设置或检索伸缩盒对象的子元素的排列方式 **/
  -webkit-line-clamp: 2; /** 显示的行数 **/
  overflow: hidden; /** 隐藏超出的内容 **/
}
</style>